MKDIR
Section: System Calls (2)
Updated: August 1, 1992
Index
Return to Main Contents
NAME
mkdir - make a directory
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
int mkdir(const char *path, mode_t mode);
DESCRIPTION
The
mkdir
function creates a new, empty directory with name path.
The mode of the new directory is initialized from the mode
argument.
The low-order nine bits of mode are modified by the process's
file mode creation mask: all bits set in the process's file mode
creation mask are cleared.
See
umask(2).
The directory's owner ID is set to the process's effective user ID.
The directory's group ID is set to that of the parent directory in
which the directory is created.
Upon successful completion, the
mkdir
function marks for update the st_atime, st_ctime and st_mtime
fields of the directory, and the st_ctime and st_mtime
fields of the parent directory in which the new directory is created.
RETURN VALUE
Upon successful completion, the
mkdir
function returns a value of zero.
Otherwise, a value of -1 is returned and errno is set to indicate
the error.
ERRORS
If any of the following conditions occurs, the
mkdir
function returns -1 and set errno to the corresponding value:
- [EACCES]
-
Search permission is denied for a component of the path prefix,
or write permission is denied on the parent directory
in which the new directory is to be created.
- [EDQUOT]
-
The directory in which the entry for the new directory
is being placed cannot be extended because the
user's quota of disk blocks on the file system
containing the directory has been exhausted;
or,
the user's quota of disk blocks on the file system that will
hold the contents of the new directory has been exhausted;
or,
the user's quota of inodes on the file system on
which the directory is being created has been exhausted.
- [EEXIST]
-
The named file exists.
- [EFAULT]
-
The path argument points outside the process's allocated address space.
- [EINVAL]
-
The pathname contains a character with the high-order bit set.
- [EIO]
-
An I/O error occurred while making the directory entry
or allocating the inode; or
an I/O error occurred while reading from
or writing to the file system.
- [ELOOP]
-
Too many symbolic links were encountered in translating the pathname.
- [EMLINK]
-
The link count of the parent directory in which the new directory to be
created would exceed {LINK_MAX} (see
<limits.h>)
(POSIX only).
- [ENAMETOOLONG]
-
A component of
path
exceeds 255 characters,
or the entire pathname exceeds 1023 characters.
For POSIX applications these values are given
by the constants {NAME_MAX} and {PATH_MAX}, respectively.
- [ENOENT]
-
A component of the path prefix does not exist,
or the path argument points to an empty string.
- [ENOSPC]
-
The directory in which the entry for the new directory is being placed
cannot be extended because there is no space left on the file
system containing the directory;
or,
there is no space left on the file
system to hold the contents of the new directory;
or,
there are no free inodes on the file system on which the
directory or the contents of the new directory are being created.
- [ENOTDIR]
-
A component of the path prefix is not a directory.
- [EPERM]
-
The path argument contains a byte with the high-order bit set.
- [EROFS]
-
The parent directory of the new directory being created resides in a
read-only file system.
SEE ALSO
chmod(2),
stat(2) or stat(2P),
umask(2)
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- RETURN VALUE
-
- ERRORS
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 17:22:52 GMT, March 25, 2025